home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Java for 3D & VRML Worlds
/
Java for 3d and VRML Worlds.iso
/
examples
/
chap04
/
SwitchAgent.java
< prev
next >
Wrap
Text File
|
1996-09-20
|
867b
|
32 lines
//
// an agent raises his hand when you click him.
//
import vrml.*;
import vrml.node.*;
import vrml.field.*;
public class SwitchAgent extends Script{
SFInt32 setAgentImage;
boolean normalPosture = true;
public void initialize(){
// get the reference of the event out 'setAgentImage'.
setAgentImage = (SFInt32)getEventOut("setAgentImage");
}
public void processEvent(Event e){
if(e.getName().equals("touchTime") == true){
// toggle the state.
normalPosture = !normalPosture;
if(true == normalPosture){
// make the agent in normal posture.
setAgentImage.setValue(0);
}else{
// make the agent in hello posture.
setAgentImage.setValue(1);
}
}
}
}